package com.ghck.server.dao;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.ghck.server.dao.provider.SmsVerificationProvider;
import com.ghck.server.model.SmsVerification;
import com.ghck.server.model.query.SmsVerificationQuery;
/**
 * 短信验证码  <br>
 * t_sms_verification <br>
 * v1.0 2016-05-01
 */
 public interface SmsVerificationMapper {
 	
 	/**
 	*根据id删除 短信验证码
 	*/
 	@Delete("delete from t_sms_verification where id=#{id}")
 	public Integer deleteById(Integer id);
 	
 	/**
 	* 批量新增 短信验证码
 	*/
 	@InsertProvider(method="batchInsert",type=SmsVerificationProvider.class)
	@Options(useGeneratedKeys=true,keyColumn="id",keyProperty="list[0].id")
 	public Integer batchInsert(List<? extends SmsVerification> smsVerifications);
 	
 	/**
 	* 新增 短信验证码
 	*/
 	@InsertProvider(method="insert",type=SmsVerificationProvider.class)
	@Options(useGeneratedKeys=true)
 	public Integer insert(SmsVerification domain);
 
 	
 	/**
 	*更新 短信验证码
 	*/
 	@UpdateProvider(method="update",type=SmsVerificationProvider.class)
 	public Integer update(SmsVerification domain);
 	
 	/**
 	*根据ID查询 短信验证码
 	*/
	@Select("select * from t_sms_verification where id=#{id}")
	public SmsVerification findById(Integer id);
	
	/**
 	*通过query 查询 短信验证码
 	*/
 	@SelectProvider(method="findByQuery",type=SmsVerificationProvider.class)
 	public List<SmsVerification> findByQuery(SmsVerificationQuery query);
 	
 	/**
 	*通过query count总条数
 	*/
 	@SelectProvider(method="countByQuery",type=SmsVerificationProvider.class)
 	public Integer countByQuery(SmsVerificationQuery query);
 	
 	/**
 	* 通过ids查询
 	*/
 	@SelectProvider(method="findByIds",type=SmsVerificationProvider.class)
 	public List<SmsVerification> findByIds(List<Integer> ids);
 	
 	/**
 	*根据mobile查询最近的一条 短信验证码
 	*/
	@Select("select * from t_sms_verification where mobile=#{mobile} order by id desc limit 1")
	public SmsVerification findLastByMobile(String	mobile);
 	

}	